package org.example.examfx02.entity;

import java.util.ArrayList;
import java.util.List;

public class UserGroup {
    private List<Teacher> teachers;
    private List<Student> students;
    private Admin admin = Admin.getInstance();
    public UserGroup(){
        this.students = new ArrayList<>();
        this.teachers = new ArrayList<>();
    }
    // get set
    public List<Teacher> getTeachers() {
        return teachers;
    }
    public void setTeachers(List<Teacher> teachers) {
        this.teachers = teachers;
    }
    public List<Student> getStudents() {
        return students;
    }
    public Student getStudentById(String id){
        for(int i = 0;i<students.size();i++){
            if(students.get(i).equals(id)){
                return students.get(i);
            }
        }
        return null;
    }
    public void setStudents(List<Student> students) {
        this.students = students;
    }
    public Teacher getTeacherByID(String id){
        for(int i = 0;i<teachers.size();i++){
            if(teachers.get(i).getWorkId().equals(id)){
                return teachers.get(i);
            }
        }
        return null;
    }
    public Teacher getTeacherByInfo(String info){
        for(int i = 0;i<teachers.size();i++){
            if(teachers.get(i).toString().equals(info)){
                return teachers.get(i);
            }
        }
        return null;
    }
    public ArrayList<String> getTeachersInfo(){
        ArrayList<String> teacherInfo = new ArrayList<>();
        for(int i = 0;i<teachers.size();i++){
            teacherInfo.add(teachers.get(i).toString());
        }
        return teacherInfo;
    }
    public void updateStu(Student student){
        for(int i = 0;i<students.size();i++){
            if(students.get(i).getId().equals(student.getId())){
                students.set(i,student);
            }
        }
    }
    public void updateTea(Teacher teacher){
        for(int i = 0;i<teachers.size();i++){
            if(teachers.get(i).getWorkId().equals(teacher.getWorkId())){
                teachers.set(i,teacher);
            }
        }
    }
}
